home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
- From: grantp@usa.pipeline.com(Pete Grant)
- Newsgroups: comp.lang.c++,
- Subject: Re: template problem
- Date: 28 Mar 1996 11:37:31 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4jdtlr$21r@news1.h1.usa.pipeline.com>
- References: <4jd9dv$27g@mirv.unsw.edu.au>
- NNTP-Posting-Host: 38.8.60.8
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete Grant)
- X-Newsreader: Pipeline v3.5.0
-
- On Mar 28, 1996 05:51:59 in article <template problem>,
- 'jeroen@fatboy.gas.unsw.edu.au (Jeroen Dijkmeijer)' wrote:
-
-
- >Problem with templates and friend declaration
- >G'day
- >
- >I haven't much of C++ experience. But I'm studying hard to learn. At this
-
- >moment I do have a problem with templates. The example is taken from
- Deitel &
- >Deitel C++ how to program ch 15 pg 697
- >
- >The files are listed below.
- >
- >
- >// file listnode.h
- >// List template definition
- >
- >#ifndef LISTNODE_H
- >#define LISTNODE_H
- >
- >template<class DATA_TYPE>
- >class ListNode {
- >friend class List<DATA_TYPE>;
- >public:
- >ListNode(const DATA_TYPE &); //constructor
- >DATA_TYPE getData() const;
- >private:
- >DATA_TYPE data; // data
- >ListNode *nextPtr;
- >};
- [... rest of code deleted ..]
-
- >"listnode.h", line 9: error(3358): invalid friend declaration
- >friend class List<DATA_TYPE>;
- >
-
- You need a forward declaration for template class List:
-
- template<class T> class List;
-
- Place it in file listnode.h after the line #define LISTNODE_H
-
- --
- Pete Grant
- Kalevi, Inc.
- Software Engineering & development
-